<?php
/*  This is a simple wrapper around the DBConnection.php and DBStatement.php files.  This is
 *  configured to be used with the CLR database.
 */

require_once 'DBConnection_IBM_DB2.php';

define(DB_HOST, 'localhost');
define(DB_PORT, 50001);
//define(DB_DBNAME, 'CLRDB');
define(DB_DBNAME, 'CONFER');
define(DB_SCHEMA, 'DB2INST1');
define(DB_USERNAME, '');
define(DB_PASSWORD, '');

$dbConnection = NULL;

function ConnectToDB() {
	global $dbConnection;
	$dbConnection = new Connection_IBM_DB2(DB_DBNAME, DB_SCHEMA, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
	if (!$dbConnection->connected()) {
		die($dbConnection->SQLErrorMSG);
	}
	return $dbConnection;
}

function DBExecute($sql, $params = NULL) {
	global $dbConnection;
	$req = NULL;
	if (!isset($params)) {
		$req = $dbConnection->newStatement($sql);
	} else {
		$req = $dbConnection->newStatement($sql, true);
		if (!$req->prepSuccessful()) die($req->errorMsg());
		$req->execute(is_array($params) ? $params : array($params));
	}
	if (!isset($req) || !$req->execSuccessful()) die($req->errorMsg());//die($resourceReq->errorMsg());
	return $req;
}
?>
